package com.gxa.service.parking.impl;



import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.dto.parking.PRegionDto;
import com.gxa.dto.parking.PRegionSearchDto;
import com.gxa.entity.parking.PRegion;
import com.gxa.entity.parking.Parking;
import com.gxa.mapper.parking.PRegionMapper;
import com.gxa.service.parking.PRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-11 10:05:39
 */
@Service
public class PRegionServiceImpl extends ServiceImpl<PRegionMapper, PRegion> implements PRegionService {
    @Autowired
    private PRegionMapper pRegionMapper;


    @Override
    public PageInfo<PRegionDto> queryAll(PRegionSearchDto pRegionSearchDto, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<PRegionDto> pRegionDtos = pRegionMapper.queryALl(pRegionSearchDto.getRegionNum(),pRegionSearchDto.getRegionName(),pRegionSearchDto.getParkingName());
        PageInfo<PRegionDto> pRegionDtoPageInfo = new PageInfo<>(pRegionDtos);
        return pRegionDtoPageInfo;
    }

    @Override
    public List<Parking> queryParking() {
        List<Parking> parkings = pRegionMapper.queryAllParking();
        return parkings;
    }

    @Override
    public PRegion getById(Integer id) {
        PRegion pRegion = pRegionMapper.selectById(id);
        return pRegion;
    }

    @Override
    public void add(PRegion pRegion) {
        pRegionMapper.insert(pRegion);
    }

    @Override
    public void delete(Integer id) {
        pRegionMapper.deleteById(id);
    }

    @Override
    public void update(PRegion pRegion) {
        pRegionMapper.updateById(pRegion);
    }
}
